{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8e997571-46ea-4a1c-9caf-d6659e149492",
   "metadata": {},
   "source": [
    "# Sentiment analysis with the Perceptron algorithm & statsmodels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "eebbfbaf-db59-4b11-938b-434847d2f210",
   "metadata": {},
   "outputs": [],
   "source": [
    "%run Coding_perceptron_algorithm.ipynb # Import the code we wrote\n",
    "\n",
    "from matplotlib import pyplot as plt\n",
    "import numpy\n",
    "\n",
    "numpy.random.seed(0) # So we get the same results"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58b87098-b24d-4fc3-9dea-044555da23c8",
   "metadata": {},
   "source": [
    "## Example 1\n",
    "\n",
    "Our dataset will have a few points and two classes, 1 and 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bbc10e90-d250-4e88-b36b-5e94f0635489",
   "metadata": {},
   "outputs": [],
   "source": [
    "features = numpy.array([\n",
    "     [0,2],\n",
    "     [1,0],[1,1],[1,2],[1,3],\n",
    "     [2,2],[2,3],[3,2]\n",
    "    ])\n",
    "labels = numpy.array([0,0,0,0,1,1,1,1])\n",
    "\n",
    "data = numpy.column_stack((features, labels))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dc5a687a-651e-4c42-9674-38bdb8a275fd",
   "metadata": {},
   "source": [
    "### Plotting the points\n",
    "\n",
    "We only need the full array because matplotlib doesn't support passing in multiple markers. We're also giving our guess for a splitting line."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4a33d5c2-0beb-4b94-8fb7-cc663f17fdc1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAp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aU8hCZ0pZTyEJrQlVLKQ/w/GXZ0Z3u8xTgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_scatter(data[labels == 0,0], data[labels == 0,1], marker = '^')\n",
    "plot_scatter(data[labels == 1,0], data[labels == 1,1], marker = 's')\n",
    "plt.legend([\"Happy\", \"Sad\"])\n",
    "draw_line(-1,3.5, ending = 3)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5045d1b-56e4-42e5-8389-186a4cd66fea",
   "metadata": {},
   "source": [
    "### Some pieces of the perceptron algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e3829192-e182-4f84-b6de-0d2252dc4cd5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 0 0\n",
      "0 -3 0\n",
      "0 -1 0\n",
      "1 1 1\n",
      "1 3 0\n",
      "1 2 0\n",
      "1 4 0\n",
      "1 3 0\n"
     ]
    }
   ],
   "source": [
    "#weights = [1,1]\n",
    "#bias = -3.5\n",
    "weights = numpy.array([1,2])\n",
    "bias = -4\n",
    "\n",
    "# \n",
    "for i in range(len(features)):\n",
    "    print(\n",
    "        prediction(features[i], weights, bias),\n",
    "        calculate_score(features[i], weights, bias),\n",
    "        calculate_error(features[i], weights, bias, labels[i]),\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1fd7b34d-40c0-4b84-b029-edf57703322d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.125"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "calculate_mean_perceptron_error(features, weights, bias, labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "091c6e49-b4d8-4a27-8fa5-663ff3ce4ed9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([0.98, 1.97]), -4.01)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# weights_i, bias_i\n",
    "perceptron_trick(features[6], weights, bias, 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e8f33f17-3a5e-4a03-8c80-da6723f078f4",
   "metadata": {},
   "source": [
    "### Running the full algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "44cade0c-3ef7-494a-b39b-dccf9a3ff84c",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|                                                                                          | 0/200 [00:00<?, ?it/s]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEICAYAAABPgw/pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAgMklEQVR4nO3de5hcdZ3n8fcnnVY7ijRIdE0HSERkjJfQ2IIj68qgTri40uN6AUcFh5HlWXHERSQZXUXUB3YZVmaeUVlk1PEyQtQY0TAmKsO4Dy4jHZOAwMQJF0k6KAHS4tA9Q6fz3T/OqXBSqcvp7qquqlOf1/P0U3Uuderbdfn2r7/nd34/RQRmZtb55rU6ADMzawwndDOzgnBCNzMrCCd0M7OCcEI3MysIJ3Qzs4JwQreOJOkISf8qqafVsdj0+f1rDif0FpD0gKQnJR1Wtn6zpJC0ZI7jOUnS3vQL9jtJWyW9Zy5jqCd9zV5fWo6IByPiWREx1YTnCklPpK9H6efDjX6eVkp/xxem9y+V9LUmP9+cvX/dzAm9de4HziotSHoZ0Ne6cNgZEc8Cng1cAnxB0rLpHEDS/KZE1hrL04RT+vlflXYq/52VyP29mu7+0zUX70nB3veO5oTeOl8F3p1ZPhv4SnY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P2XnjOPttIRebTLqtiRpCTAI/BPwvNIsTuntc1sYWrmrST5U2fmx2jXeFwC7gC+lJaLrJD2TNo03IkaBvyBpgT1EMpvXBto03jLVYuyE7+GfAH+f3m/LeCW9CRiNiC1lm2Ycb6cl9FyTUbcDSc8Cvg1cGBGPtzqeaiS9EXg4Ija2Opac5gPHAZ+PiEHgCVpfrqgqrTufASwFFgHPlPTO1kY1a239PZT0EZLS59dLqyrs1tJ4JS0APgJ8rNLmCutyxdtpCb0jJqOW1EuSzL8eEWvS1b+R9Px0+/OBh1sVX5kTgTdJeoCkhHWypK/RvvHuAHZExD+ly98iSfDtGu/rgfsjYldETAJrgFfTvvFmVYuxbb+Hks4G3gj8cTx1kU07xnsUyR/5Lel3bzHwc0n/gVnE22kJfd+E1ZKeRnLi4MYWx7QfSSKp794TEf87s+lG4Oz0/tnAd+c6tkoiYlVELI6IJSSv580R8U7aN95fA9sllaZKfx1wN20aL0mp5VWSFqSfjdeRnFdp13izqsV4I3CmpKcrmTz+aOBnLYhvP5JOAS4B3hQR45lNbRdvRNwZEc+NiCXpd28HcFz6+Z55vBHRUT8kk1H/ErgX+Eir46kQ338k+ffoDmBz+nMa8BySngL/kt4e2upYK8R+EvD99H7bxgscC4ykr/Fa4JA2j/cTwD8DvwC+Cjy93eIFvkFS459Mk8u5tWIkKRfcC2wFTm2TeLeR1J5L37tr2jnesu0PAIfNNl5f+m9mVhCdVnIxM7MqnNDNzArCCd3MrCCc0M3MCsIJ3cysIJzQzcwKwgndzKwg/j/zD709/6nvpAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.47 0.09] -0.6800000000000004\n"
     ]
    }
   ],
   "source": [
    "weights, bias = perceptron_algorithm(features, labels)\n",
    "print(weights, bias)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "663fa43e-9109-4938-b0b1-89fc0ce6132a",
   "metadata": {},
   "source": [
    "### Plotting our results\n",
    "\n",
    "The weights we get are the coefficients of the line (plane). In our case, the weights and bias describe the line Ax + By + C = 0, so we have to calculate y = -Ax/B - C/B to get our slope and constant term."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e8558086-12d9-42cd-87fc-3086b1a05894",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAmdklEQVR4nO3deXhV9b3v8fc3ZIIkTElQmUEGhQQCRFBkErDgQFGPVj2n1qro00F7tb211j5tOZ729j6t7b3H3ntaaVX01LHYQbGnah1QFMEEqaKMCkiYElIIBAhJ2N/7R5J9AyQmsFey9k4+r+fJ8+xh7d/6rv2Db375rd/6LnN3REQkcSWFHYCIiMRGiVxEJMEpkYuIJDglchGRBKdELiKS4JLD2GlOTo4PHjw4jF2LiCSs4uLive6ee+LrgSRyM7sLWAA48AFwk7tXNbf94MGDKSoqCmLXIiKdhplta+r1mKdWzKwf8A2g0N3zgC7AdbG2KyIirRPUHHky0NXMkoFuwM6A2hURkRbEnMjdfQdwP/ApsAuocPeXYm1XRERaJ+Y5cjPrBcwHhgD7gd+b2Rfd/XcnbHcbcBvAwIEDY92tiLSgpqaGkpISqqqaPV0lcSo9PZ3+/fuTkpLSqu2DONk5G9ji7mUAZvYHYDJwXCJ390XAIoDCwkIVeBFpYyUlJWRlZTF48GDMLOxwpJXcnfLyckpKShgyZEirPhPEHPmnwPlm1s3q/rXMAtYF0K6IxKCqqors7Gwl8QRjZmRnZ5/SX1JBzJGvBJYAq6lbephE/chbRMKlJJ6YTrXfAllH7u4/BH4YRFstqampafW8kYhIZ5BQl+h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EvL4+77rqLDz/8MLr9xRdfTO/evYG6gem9997LmDFjmD17Njt27GDPnj0tfjezZs2iR48epKenM2rUKLZt28aqVauYPn06vXv3JiUlhWuuuaYV3/LxrrrqKgAmTJjA1q1bAXjppZd47LHHKCgoYNKkSZSXl7Np06ZTbruxhJojb05SUhKZmZkMGzYMgD179nDGGWeEHJVIfJkxY0b08R133BF9fNtttwEwZ86c6Gvf+ta3AMjKyuLLX/4yAPPmzYu+/93vfrdV++zSpQszZsxgxowZ5Ofn8+ijjzJhwgRGjx7NihUrmvzMiUvvzIzvf//7XHTRRfzxj39k69atxx1LRkZG9PHjjz9OWVkZxcXFpKSkMHjw4Fatx26Y/mmIuba2Fg/gxvQN7Ta0CXW/bH75y18e933HKuFH5A3S09MZMmQIR48e5a9//Wv0SxORcGzYsOG4keaaNWsYNGgQI0eOpKysLJrIa2pqjhthP/300wAsX76cHj160KNHDyoqKujXrx9A9C+EplRUVNCnTx9SUlJ47bXX2LatruprVlYWBw8ePKX4J06cyLJly9i3bx+1tbU8++yzp/T55syZM4df/epX0XN7GzdujHklXocYkTeWlpbGjTfeCMCzzz7L9OnTycnJCTkqkc6nsrKSO+64g/3795OcnMywYcNYtGgRqampLFmyhG984xtUVFRQW1vLnXfeyejRowHo1asXkydP5sCBAzz88MMA3H333dx444384he/YObMmc3u81/+5V+YN28ehYWFFBQUcM455wCQnZ3NhRdeSF5eHpdccglf//rXW4y/X79+3HvvvUyaNIm+ffsyatQoevToEfP3smDBArZu3cr48eNxd3Jzc/nTn/4UU5sWxJ8Pp6qwsNDb48YSu3fvpk+fPpSWltKtWze6d+/e5vsUiRfr1q3j3HPPDTuMUzJjxgzuv/9+CgsLww4FqPtllJmZSW1tLVdeeSU333wzV155Zbvsu6n+M7Nidz/py+kwUytNOfPMM0lKSmL79u3s2rUreoZXRKQ1Fi5cSEFBAXl5eQwZMoQrrrgi7JCa1OGmVppy3nnnAXW/4bZs2cKll14ackQi0pSGVTXxomFNeLzr0CPyE40cOZKpU6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j/7ez5Q4e672jvQVmjxWMzsTDOz+scTqeuX8naPNHaJ0iefKZH6oz7Oh4B17v6LZjZLiH5pzbEkQt+YWW79SBwz6wrMBtafsFmgfRKXUyvuXmtmtwMvUrfq42F3/9DMvlL//q+Bv1B35nczcBi4Kax4P0srj+Vq4KtmVgscAa7z+lPb8cTMnqRu1UCOmZUAP6TuRE5C9UkrjiMh+qPehcANwAf1c7IA9wIDIbH6hdYdSyL0zVnAo2bWhbpfNM+4+9K2zF+6RF9EJMHF69SKiIi0khK5iEiCUyIXEUlwSuQiIglOiVxEJMEpkYuIJDglchGRBPf/ABTKVeo9gw+lAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_scatter(data[labels == 0,0], data[labels == 0,1], marker = '^')\n",
    "plot_scatter(data[labels == 1,0], data[labels == 1,1], marker = 's')\n",
    "draw_line(\n",
    "    -weights[0]/weights[1], # slope\n",
    "    -bias/weights[1], # constant\n",
    "    ending = 3,\n",
    "    color='grey', linewidth=1.0, linestyle='dotted')\n",
    "plt.legend([\"Separating line\", \"Happy\", \"Sad\"])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36f974bc-b034-48fa-b3de-f5bc26147806",
   "metadata": {},
   "source": [
    "## Example 1 with statsmodels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "1ac43169-5475-43f3-b1be-1187a44717d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Warning: Maximum number of iterations has been exceeded.\n",
      "         Current function value: 0.000000\n",
      "         Iterations: 35\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Peanut\\miniconda3\\lib\\site-packages\\statsmodels\\base\\model.py:568: ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals\n",
      "  ConvergenceWarning)\n"
     ]
    }
   ],
   "source": [
    "import statsmodels.api as sm\n",
    "\n",
    "exog = sm.add_constant(features) # adds an intercept column\n",
    "model_logistic_regression = sm.Logit(\n",
    "    endog = labels, \n",
    "    exog = exog)\n",
    "# statsmodels will notify us if separation is perfect\n",
    "model_logistic_regression.raise_on_perfect_prediction = False\n",
    "results_regression = model_logistic_regression.fit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c5ab5702-b675-4b59-8729-81188a4b0750",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"simpletable\">\n",
       "<caption>Logit Regression Results</caption>\n",
       "<tr>\n",
       "  <th>Dep. Variable:</th>           <td>y</td>        <th>  No. Observations:  </th>   <td>     8</td>   \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Model:</th>                 <td>Logit</td>      <th>  Df Residuals:      </th>   <td>     5</td>   \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Method:</th>                 <td>MLE</td>       <th>  Df Model:          </th>   <td>     2</td>   \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Date:</th>            <td>Mon, 16 Aug 2021</td> <th>  Pseudo R-squ.:     </th>   <td> 1.000</td>   \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Time:</th>                <td>00:02:50</td>     <th>  Log-Likelihood:    </th> <td>-1.5140e-11</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>converged:</th>             <td>False</td>      <th>  LL-Null:           </th>  <td> -5.5452</td>  \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Covariance Type:</th>     <td>nonrobust</td>    <th>  LLR p-value:       </th>  <td>0.003906</td>  \n",
       "</tr>\n",
       "</table>\n",
       "<table class=\"simpletable\">\n",
       "<tr>\n",
       "    <td></td>       <th>coef</th>     <th>std err</th>      <th>z</th>      <th>P>|z|</th>  <th>[0.025</th>    <th>0.975]</th>  \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>const</th> <td> -236.2360</td> <td> 2.05e+08</td> <td>-1.15e-06</td> <td> 1.000</td> <td>-4.03e+08</td> <td> 4.03e+08</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>x1</th>    <td>   59.8652</td> <td> 3.89e+07</td> <td> 1.54e-06</td> <td> 1.000</td> <td>-7.62e+07</td> <td> 7.62e+07</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>x2</th>    <td>   70.7097</td> <td> 7.76e+07</td> <td> 9.12e-07</td> <td> 1.000</td> <td>-1.52e+08</td> <td> 1.52e+08</td>\n",
       "</tr>\n",
       "</table><br/><br/>Complete Separation: The results show that there iscomplete separation.<br/>In this case the Maximum Likelihood Estimator does not exist and the parameters<br/>are not identified."
      ],
      "text/plain": [
       "<class 'statsmodels.iolib.summary.Summary'>\n",
       "\"\"\"\n",
       "                           Logit Regression Results                           \n",
       "==============================================================================\n",
       "Dep. Variable:                      y   No. Observations:                    8\n",
       "Model:                          Logit   Df Residuals:                        5\n",
       "Method:                           MLE   Df Model:                            2\n",
       "Date:                Mon, 16 Aug 2021   Pseudo R-squ.:                   1.000\n",
       "Time:                        00:02:50   Log-Likelihood:            -1.5140e-11\n",
       "converged:                      False   LL-Null:                       -5.5452\n",
       "Covariance Type:            nonrobust   LLR p-value:                  0.003906\n",
       "==============================================================================\n",
       "                 coef    std err          z      P>|z|      [0.025      0.975]\n",
       "------------------------------------------------------------------------------\n",
       "const       -236.2360   2.05e+08  -1.15e-06      1.000   -4.03e+08    4.03e+08\n",
       "x1            59.8652   3.89e+07   1.54e-06      1.000   -7.62e+07    7.62e+07\n",
       "x2            70.7097   7.76e+07   9.12e-07      1.000   -1.52e+08    1.52e+08\n",
       "==============================================================================\n",
       "\n",
       "Complete Separation: The results show that there iscomplete separation.\n",
       "In this case the Maximum Likelihood Estimator does not exist and the parameters\n",
       "are not identified.\n",
       "\"\"\""
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results_regression.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5183d952-98df-4a58-ae24-c8177174ce4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAlJklEQVR4nO3de1RU99kv8O8zMAzIjKiARkVFoxAFFIWg8R41VWOs0cbGtE1zM1lpLn2T9CRvkrPaetLk7Tq5dL3HrNNW2yQmbe6mbRJsm1ijJipewFhjoniJGPAGEgFRYAbmOX/AzEEEGZg9s5mZ72ct1mJuez/+HL78+O29nxFVBRERhS6L2QUQEZF/GORERCGOQU5EFOIY5EREIY5BTkQU4qLN2GlSUpKmpqaasWsiopBVVFR0RlWT295vSpCnpqaisLDQjF0TEYUsETnW3v1cWiEiCnEMciKiEMcgJyIKcYatkYtIFIBCAMdV9QajtktE3eNyuVBWVob6+nqzS6Euio2NRUpKCqxWq0/PN/Jg538A2A+gt4HbJKJuKisrg8PhQGpqKkTE7HLIR6qKyspKlJWVYfjw4T69xpClFRFJAbAAwB+N2B4R+a++vh6JiYkM8RAjIkhMTOzSX1JGrZH/N4DHALg7eoKI3CMihSJSWFFRYdBuiehyGOKhqav/b34HuYjcAKBcVYsu9zxVXa2quaqam5x8yfnsPnO5XN1+LRFRODJiRj4FwHdFpATAWwBmicifDdjuJdxuN/74xz/i/Pnzgdg8ERnsmWeeQUZGBsaOHYvs7Gzs2LHDlDqqqqrw29/+1nv7xIkTuOmmmwzZ9po1a/DAAw8AAH7/+9/jtddeM2S7XeH3wU5VfQLAEwAgIjMB/A9V/ZG/222PxWLBnXfeCZvNht27d2PIkCHwZ3ZPRIFTUFCA/Px87N69GzabDWfOnIHT6QzY/hobGxEd3X6keYL8vvvuAwAMGjQIa9euNbyGe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PMGCtf6jKFqp5U1d0t358DsB9A2w9VDPqY+VhX0LWMQW3LTWvLV9uzJMwYL1/qMoWIpABYAOCPHTzF0PHqqUE+GEBpq9tluPQN7ctzzKgLAK5p+XPvHyKSEeCafGHGWPnK1LESkVQA49E8m2vN1DG7TF2ACWPWskywB0A5gPWq2iPGy4e6AHPeY/8N4DEA7g4eN3S8emqQt9dOse1vWl+eYzRf9rkbwDBVHQfgRQB/C3BNvjBjrHxh6liJiB3AewAeUtWatg+385KgjFkndZkyZqrapKrZAFIA5IlIZpunmDJePtQV9PESkRsAlKtq0eWe1s593R6vnhrkZQCGtLqdAuBEN54T9LpUtcbz556q/h2AVUSSAlxXZ8wYq06ZOVYiYkVzWL6uqn9p5ymmjFlndZn9/lLVKgCbAMxr85Cp77GO6jJpvKYA+K6IlKB5+XWWiPy5zXMMHa+eGuS7AIwSkeEiEgNgGYAP2jznAwA/bjn6OwlAtaqeNLsuEblCpLlBu4jkoXmMKwNcV2fMGKtOmTVWLft8CcB+Vf1NB08L+pj5UpcZYyYiySLSp+X7OABzABxo8zQzxqvTuswYL1V9QlVTVDUVzRnxiar+qM3TDB0vvy7RDxRVbRSRBwB8hOYzRV5W1S9F5N6Wx38P4O9oPvJ7GMAFAHf0kLpuAvATEWkEUAdgmbYcpg4UEXkTzUfnk6S5980v0Xzgx7Sx8rGuoI9ViykAbgXwRcv6KgA8CWBoq9rMGDNf6jJjzAYCeFVEotAchO+oar7ZP48+1mXWe+wSgRwvXqJPRBTieurSChER+YhBTkQU4hjkREQhjkFORBTiGORERCGOQU5EFOIY5EREIe7/AdC153BnShtLAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_scatter(data[labels == 0,0], data[labels == 0,1], marker = '^')\n",
    "plot_scatter(data[labels == 1,0], data[labels == 1,1], marker = 's')\n",
    "draw_line(\n",
    "    -results_regression.params[2]/results_regression.params[1],\n",
    "    -results_regression.params[0]/results_regression.params[1],\n",
    "    starting=0, \n",
    "    ending=sum(labels),\n",
    "    color='grey', linewidth=1.0, linestyle='dotted')\n",
    "plt.legend([\"Separating line\", \"Happy\", \"Sad\"])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4054ba6-63a8-4bff-a15d-38355357186a",
   "metadata": {},
   "source": [
    "## Example 2: Splitting points with a plane\n",
    "\n",
    "We alluded to a plane multiple times. Now let's see it in practice"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97afd3cb-3be7-4277-9dab-2a8bf3d54a39",
   "metadata": {},
   "source": [
    "### Plotting a plane\n",
    "\n",
    "We'll need to plot a plane by forming a grid of points."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d7e96008-08b2-42e9-b063-c9e69fabacdc",
   "metadata": {},
   "outputs": [],
   "source": [
    "def plot_plane(normal, constant, **kwargs):\n",
    "    \"\"\"\n",
    "    Normal vector is the vector normal to the plane\n",
    "\n",
    "    Obviously trying more than three dimemsions will cause some trouble\n",
    "    \"\"\"\n",
    "    # Add an axes by creating x1, ..., x_n-1\n",
    "    num_dimensions = len(normal) - 1\n",
    "    grid_points = numpy.meshgrid(*[range(10)]*num_dimensions)\n",
    "    grid_points = numpy.array(grid_points)\n",
    "    # calculate corresponding z = -sum( xi*ai )/xn - constant\n",
    "    z = 0\n",
    "    for index, coefficient in enumerate(normal[:-1]):\n",
    "        z += coefficient*grid_points[index]\n",
    "    z = numpy.divide(z, normal[-1])\n",
    "    z = numpy.add(z, constant)\n",
    "    z = -z\n",
    "\n",
    "    fig = plt.figure()\n",
    "    ax = fig.add_subplot(111,projection='3d')\n",
    "\n",
    "    # plot the surface\n",
    "    ax.plot_surface(*grid_points, z, alpha=0.2)\n",
    "\n",
    "    return ax"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a49fc543-3350-4bde-a0a5-a0e06ef647d8",
   "metadata": {},
   "source": [
    "### Defining our dataset and running the algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "913a52ad-ecc2-454f-88fd-1d893861899b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|                                                                                          | 0/300 [00:00<?, ?it/s]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAEICAYAAAB25L6yAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYHklEQVR4nO3de5BcZZ3G8e9DiDBAMCKjZRKGIGhKBLmNomZ12YibCKyyqKVYIuyiWWvRRVfAYFkLXtikFldxa3d1Ee+gC3KJiC4XjYiigBMS5RJTyz0XJOESuZiV22//OGdCp9N9+sxMn+63p59P1dR0n/f06Xfe7nnmzPu+521FBGZmlq7tul0BMzMr5qA2M0ucg9rMLHEOajOzxDmozcwS56A2M0ucg9qSImlI0uOSpnS7LjZ2fv2q4aBuI0n3SHpS0u5121dKCkmzO1yfwyQ9m//iPCZptaS/6WQdWsnb7PDR+xFxX0TsEhHPVPBcIemJvD1Gv05r9/N0U/4z7pPfPlPS+RU/X8dev37moG6/u4FjR+9I2h8Y6F51WB8RuwC7Ah8HviJp37EcQNL2ldSsOw7Ig2T0618a7VT/MytT+vdlrPuPVSdek0n2uvc0B3X7fRt4X83944Fv1e4gaQdJn5N0n6QHJH1Z0kBe9gJJV0jaKOmR/PasmsdeK+kzkq7Pz5Kvrj+DbyQyS4FHgH0lbSdpkaQ7JT0k6SJJu+XPMTs/MztR0n3Asnz7ByStyp/3dkkH59tnSLokr/Pdkv6hpr5nSrpY0oX5426WdEBe9m1gCPjB6NltzXNvX3PsyyU9LOkOSR+oO/ZFkr6VH/s2ScNjeK1qX5PRep4v6VHghLytz5J0PfBH4KWSXi/p15L+kH9/f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es>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = [numpy.random.randint(0,10, size = 3) for i in range(5)]\n",
    "x = numpy.array(x)\n",
    "y = [numpy.random.randint(0,2) for i in range(5)]\n",
    "y = numpy.array(y)\n",
    "w, b = perceptron_algorithm(x,y, learning_rate = 0.01, num_epochs = 300)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "2e9006a1-5622-425b-93ab-d9682cc6415e",
   "metadata": {},
   "outputs": [],
   "source": [
    "### Plotting our results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7ee26e4b-736f-4f15-a70d-2dbe0e02f2a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Enabling the `widget` backend.\n",
    "# This requires jupyter-matplotlib a.k.a. ipympl.\n",
    "# ipympl can be install via pip or conda.\n",
    "%matplotlib widget"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0db37c7c-5f58-4c0f-bd44-70de788443d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4d4c358a04c946df8aaa5e6ee3fdc4bc",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = plot_plane(w,b)\n",
    "ax.scatter(x[:,0], x[:,1], x[:,2], c = y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "782c6333-2ba6-4b09-a013-a0f29611e880",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
